<!--
 * @Author: your name
 * @Date: 2021-08-11 15:50:42
 * @LastEditTime: 2021-08-28 14:35:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \doctor\src\components\aside\aside.vue
-->
<template>
  <div id="aside">
    <el-container>
      <el-aside width="200px">
        <el-menu
          :default-active="menuIndex"
          background-color="#192e5b"
          active-text-color="#F2A128"
          text-color="#72A2C0"
          unique-opened
          class="content-box"
          router
          @select="getIndex"
        >
          <el-menu-item index="1" :route="{ path: '/main/homePage' }">
            <i class="el-icon-menu"></i>
            <span slot="title">首页</span>
          </el-menu-item>
          <el-submenu index="2" v-if="flag1">
            <template slot="title">
              <i class="el-icon-potato-strips"></i>菜品
            </template>
            <el-menu-item index="2-1" :route="{ path: '/main/menuCategory' }"
              >菜品类别</el-menu-item
            >
            <el-menu-item index="2-2" :route="{ path: '/main/menuFile' }"
              >菜品档案</el-menu-item
            >
            <el-menu-item index="2-3" :route="{ path: '/main/dishTaste' }"
              >菜品口味</el-menu-item
            >
            <el-menu-item index="2-4" :route="{ path: '/main/secificationMag' }"
              >规格管理</el-menu-item
            >
            <el-menu-item index="2-5" :route="{ path: '/main/dishUnit' }"
              >菜品单位</el-menu-item
            >
          </el-submenu>
          <el-submenu index="3" v-if="flag2">
            <template slot="title">
              <i class="el-icon-house"></i>库存
            </template>
            <el-menu-item index="3-1" :route="{ path: '/main/dishesStock' }"
              >菜品库存</el-menu-item
            >
            <el-menu-item index="3-2" :route="{ path: '/main/inventoryCount' }"
              >库存盘点</el-menu-item
            >
          </el-submenu>
          <el-submenu index="4" v-if="flag3">
            <template slot="title">
              <i class="el-icon-s-shop"></i>促销
            </template>
            <el-menu-item index="4-1" :route="{ path: '/main/coupon' }"
              >优惠券管理</el-menu-item
            >
            <el-menu-item index="4-2" :route="{ path: '/main/bundle' }"
              >热卖套餐</el-menu-item
            >
            <el-menu-item index="4-3" :route="{ path: '/main/campaign' }"
              >促销商品</el-menu-item
            >
          </el-submenu>
          <el-submenu index="5" v-if="flag4">
            <template slot="title">
              <i class="el-icon-tickets"></i>订单
            </template>
            <el-menu-item
              index="5-1"
              :route="{ path: '/main/orderInformation' }"
              >订单信息</el-menu-item
            >
          </el-submenu>
          <el-submenu index="6" v-if="flag5">
            <template slot="title"> <i class="el-icon-coin"></i>报表 </template>
            <el-menu-item index="6-1" :route="{ path: '/main/Dishessales' }"
              >菜品销售</el-menu-item
            >
            <el-menu-item index="6-2" :route="{ path: '/main/Cashflow' }"
              >收银流水</el-menu-item
            >
            <el-menu-item index="6-3" :route="{ path: '/main/Dishesflow' }"
              >菜品流水</el-menu-item
            >
            <el-menu-item index="6-4" :route="{ path: '/main/Storerevenue' }"
              >店铺营收</el-menu-item
            >
            <el-menu-item index="6-5" :route="{ path: '/main/Userdata' }"
              >用户数据</el-menu-item
            >
          </el-submenu>
          <el-submenu index="7" v-if="flag6">
            <template slot="title">
              <i class="el-icon-setting"></i>系统
            </template>
            <el-menu-item
              index="7-1"
              :route="{
                name: 'BannerAdmin',
                params: { placeholderName: '输入Banner名称进行搜索' },
              }"
              >banner管理</el-menu-item
            >
            <el-menu-item
              index="7-2"
              :route="{
                name: 'CouponType',
                params: { placeholderName: '输入类型名称进行搜索' },
              }"
              >优惠卷类型管理</el-menu-item
            >
            <el-submenu index="7-3">
              <template slot="title">门店配置</template>
              <el-menu-item index="7-3-1" :route="{ path: '/main/staffinfo' }"
                >员工信息</el-menu-item
              >
              <el-menu-item index="7-3-2" :route="{ path: '/main/shopinfo' }"
                >门店信息</el-menu-item
              >
              <el-menu-item index="7-3-3" :route="{ path: '/main/stafflogin' }"
                >员工登录日志</el-menu-item
              >
              <el-menu-item index="7-3-4" :route="{ path: '/main/position' }"
                >职位管理</el-menu-item
              >
              <!-- <el-menu-item index="7-3-5" :route='{path:"/main/jurisdiction"}'>权限管理</el-menu-item> -->
            </el-submenu>
            <el-submenu index="7-4">
              <template slot="title">桌位管理</template>
              <el-menu-item index="7-4-1" :route="{ path: '/main/tableArea' }"
                >桌位区域</el-menu-item
              >
              <el-menu-item index="7-4-2" :route="{ path: '/main/tableList' }"
                >桌位列表</el-menu-item
              >
            </el-submenu>
            <el-menu-item index="7-5" :route="{ path: '/main/scanOrder' }"
              >扫码点餐配置</el-menu-item
            >
            <el-menu-item index="7-6" :route="{ path: '/main/pay' }"
              >支付设置</el-menu-item
            >
          </el-submenu>
        </el-menu>
      </el-aside>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menuIndex: sessionStorage.getItem('menuIndex') ? sessionStorage.getItem('menuIndex') : '1',
      flag1:true,
      flag2:true,
      flag3:true,
      flag4:true,
      flag5:true,
      flag6:true,
      flag7:true,
    }
  },
  mounted(){
   this.asideArr=JSON.parse(sessionStorage.getItem('aside'))
  //  console.log('sdad',this.asideArr);
   if(this.asideArr==null) return;
   this.asideArr.forEach(item=>{
     if(item.menuName==="菜品"){
       this.flag1=true;
     }
     if(item.menuName==="库存"){
       this.flag2=true;
     }
     if(item.menuName==="促销"){
       this.flag3=true;
     }
     if(item.menuName==="订单"){
       this.flag4=true;
     }
     if(item.menuName==="报表"){
       this.flag5=true;
     }
     if(item.menuName==="系统"){
       this.flag6=true;
     }
   })
   console.log('sss',this.asideArr);
 },
  methods: {
    getIndex(index) {
      // 将当前点击导航的index存储到本地
      sessionStorage.setItem('menuIndex', index);
      // console.log('当前点击的页码',index);
      this.menuIndex = index
    }
  }
}
</script>

<style lang='less' scoped>
#aside {
  height: 100%;
  background-color: #192e5b;
  border-top: 1px solid #72a2c0;
  box-sizing: border-box;
  // position: fixed;
}
.content-box {
  border-right: none;
}
i {
  color: #fff;
}
</style>